package com.audaque.springboot.foshanupload.web.openfeigndemo.controller;

import com.audaque.springboot.foshanupload.web.openfeigndemo.model.dto.FeignDto;
import com.audaque.springboot.foshanupload.web.openfeigndemo.model.req.FeignReq;
import com.audaque.springboot.foshanupload.web.openfeigndemo.service.FeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Objects;

@Slf4j
@RequestMapping("/feign")
@RestController
public class FeignController implements FeignService {

    @GetMapping("/get1")
    public String get1() {
        long threadId = Thread.currentThread().getId();
        log.debug("threadId："+threadId);
        return "get1";
    }

    @GetMapping("/get2/{param}")
    public String get2(@PathVariable("param") String param) {
        return param;
    }

    @PostMapping("/post1")
    public FeignDto post1(@RequestBody FeignReq req) {
        Integer id = req.getId();
        if (Objects.equals(id, Integer.valueOf(1))) {
            return FeignDto.builder().id(1).name("first").build();
        }
        return null;

    }
}




